package com.ff.javamonkey.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.ff.javamonkey.R;
import com.ff.javamonkey.sqlite.type.Acrlac;
import com.ff.javamonkey.sqlite.type.AcrlacDb;
import com.ff.javamonkey.sqlite.type.Group;

public class AcrldbListAdapter extends BaseGroupAdapter<AcrlacDb> {
	// Debugging
	private static final String TAG = "AcrldbListAdapter";
	
	private LayoutInflater mInflater;
	
	public AcrldbListAdapter(Context ctx) {
		super(ctx);
		mInflater = LayoutInflater.from(ctx);
	}
	
	@Override
	public void setGroup(Group<AcrlacDb> g) {
		super.setGroup(g);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.list_arcl_item, null);
			viewHolder = new ViewHolder();
			viewHolder.description = (TextView)convertView.findViewById(R.id.txtArclItemDescription);
//			viewHolder.fileIcon = (ImageView)convertView.findViewById(R.id.imgSqliteItem);
			viewHolder.runningStatus = (TextView)convertView.findViewById(R.id.txtArclItemStatus);
//			viewHolder.downloadingBar = (ProgressBar)convertView.findViewById(R.id.progressBarDownloading);
			convertView.setTag(viewHolder);
		}
		else {
			viewHolder = (ViewHolder)convertView.getTag();
		}
		AcrlacDb acrlac = (AcrlacDb) getItem(position);
		viewHolder.description.setText(acrlac.getmFileName());
		viewHolder.runningStatus.setText(acrlac.getmContent() + " items");
//		if (acrlac.isDownloading()) {
//			viewHolder.runningStatus.setVisibility(View.GONE);
//			viewHolder.downloadingBar.setVisibility(View.VISIBLE);
//			viewHolder.downloadingBar.setProgress(acrlac.getProgress());
//		}
		return convertView;
	}

	private static class ViewHolder {
		TextView description;
		TextView runningStatus;
		ProgressBar progressBar;
	}
}
